import React from 'react';
import loadjs from 'loadjs';
import { WeaTools, WeaDialog, WeaLocaleProvider } from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
import { emailFiles } from '../constants/fileConfig';

export default class SendEmail extends React.Component{
    constructor(){
        super();
        this.state = {hasLoad: false};
    }
    componentDidMount(){
        const init = () =>{
            this.setState({hasLoad:true});
        }
        loadjs.isDefined('email') ? loadjs.ready('email', init) : loadjs(emailFiles, 'email', init);
    }
    render(){
        const { hasLoad } = this.state;
        if(hasLoad){
            const { EmailNewForDialog : SendEmail } = window.weaEmail.components || {};
            const { visible = false,fwquery = {},closeFun = ()=>{},fromCb = false } = this.props;
            return (
                <SendEmail ecId={`${this && this.props && this.props.ecId || ''}_SendEmail@qkvyku`} visible={visible} fwquery={fwquery} fromCb={fromCb} onCancel={()=>{closeFun()}} />
            );
        }else{
            return (<div></div>);
        }
        
    }
}